import React, { memo, useEffect, useState } from "react"
import "./index.less"

const Rate = (props) => {
    console.log(props)

    const [score, setScore] = useState(0) // 评分数值
    const [disabled, setDisabled] = useState(false) // 是否禁用评分选择  默认是false 即可以进行评分

    useEffect(()=>{
        a()
    },[score])

    const a = () => {
        let width = Number(score * 100 - Math.floor(score) * 100) + '%' // 去设置半颗星的宽度
        return width
    }

    const choice = (index) => { // 点击设置分数
        console.log('choice', index + 1)
      }

    const isChoice = (index) => {
        // return index + 1 <= this.childScore ? 'icon-star' : 'icon-star-o'
    }

    const arr = [1, 2, 3, 4, 5]

    return (
        <div className="smd-rate">
            {
                arr.map(item => <i key={item} className="iconfont icon-xingxingshixin"  onClick={() => choice(item)} ></i>)
            }
       
        </div>
    )
}

export default memo(Rate)
